//编写一子函数，实现数据库删除表
//参数1:数据库指针 sqlite3 * mydb
//参数2:表名 const char * tbname
//返回值:查询成功返回0,失败返回-1
#include"../include/p.h"
int delete_db(sqlite3 * mydb,const char * tbname)
{
	char sql[100];
	sprintf(sql,"drop table %s",tbname);
	printf("%s\n",sql);
	char er[100]={"no such table: my"};
	sprintf(er,"no such table: %s",tbname);
	int ret=0;
	char * errmsg=NULL;
	//参数3:函数指针，函数名可以随意取，但函数类型必须对应
	ret=sqlite3_exec(mydb,sql,NULL,NULL,&errmsg);
	if(ret!=SQLITE_OK)
	{
		if(strcmp(errmsg,er)==0)
		{
			printf("数据库中没有此表\n");
			return 2;
		}
		else
		{
			printf("drop error:%s\n",errmsg);
			return -1;
		}
	}
	printf("drop ok");
	return 0;
}
